package com.frxuexi.park2212.emp

import androidx.lifecycle.MutableLiveData
import com.frxuexi.lib_base.base.BaseViewModel
import com.frxuexi.lib_base.entity.DepartBean
import com.frxuexi.lib_base.entity.EmpBean
import com.frxuexi.lib_base.entity.EmpBeanItem
import com.frxuexi.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class EmpViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {
    var getEmps = MutableLiveData<EmpBean>()
    var getDeparts = MutableLiveData<DepartBean>()

    var addEmp = MutableLiveData<EmpBeanItem>()
    fun getEmps(){
        httpRequest({apiService.getEmps()},getEmps::postValue)
    }

    fun getDeparts(){
        httpRequest({apiService.getDeparts()},getDeparts::postValue)
    }

    fun addEmp(item: EmpBeanItem){
        httpRequest({apiService.addEmp(toBody(item))},addEmp::postValue)
    }
}